package com.nc.delivery_project.server.domain;


import java.util.Date;

/**
 * Created by miroshnik on 1/28/2015.
 * Edition by DRAGON on 28.01.2015
 */
public class Schedule {

    private int id;
    
    private Department origin;
    
    private Department destination;
    
    private double primeCost;
    
    private double sellingRate;
    
    private Date tariffDate;
    
    private LegalPerson transportCompany;
    
    private Date departureDate;
    
    private Date arrivalDate;

    private Currency currency;

    public Schedule() {
    }

    public Schedule(int id, Department origin, Department destination, double primeCost, double sellingRate,
                    Date departureDate, Date arrivalDate, Date tariffDate, LegalPerson transportCompany, Currency currency) {
        this.id = id;
        this.origin = origin;
        this.destination = destination;
        this.primeCost = primeCost;
        this.sellingRate = sellingRate;
        this.departureDate = departureDate;
        this.arrivalDate = arrivalDate;
        this.tariffDate = tariffDate;
        this.transportCompany = transportCompany;
        this.currency = currency;

    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public Department getOrigin() {
        return origin;
    }

    public void setOrigin(Department origin) {
        this.origin = origin;
    }

    public Department getDestination() {
        return destination;
    }

    public void setDestination(Department destination) {
        this.destination = destination;
    }

    public double getPrimeCost() {
        return primeCost;
    }

    public void setPrimeCost(double primeCost) {
        this.primeCost = primeCost;
    }

    public double getSellingRate() {
        return sellingRate;
    }

    public void setSellingRate(double sellingRate) {
        this.sellingRate = sellingRate;
    }

    public Date getTariffDate() {
        return tariffDate;
    }

    public void setTariffDate(Date tariffDate) {
        this.tariffDate = tariffDate;
    }

    public LegalPerson getTransportCompany() {
        return transportCompany;
    }

    public void setTransportCompany(LegalPerson transportCompany) {
        this.transportCompany = transportCompany;
    }

    public Date getDepartureDate() {
        return departureDate;
    }

    public void setDepartureDate(Date departureDate) {
        this.departureDate = departureDate;
    }

    public Date getArrivalDate() {
        return arrivalDate;
    }

    public void setArrivalDate(Date arrivalDate) {
        this.arrivalDate = arrivalDate;
    }

    public Currency getCurrency() {
        return currency;
    }

    public void setCurrency(Currency сurrency) {
        this.currency = сurrency;
    }

    @Override

    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Schedule)) return false;

        Schedule schedule = (Schedule) o;

        if (Double.compare(schedule.primeCost, primeCost) != 0) return false;
        if (Double.compare(schedule.sellingRate, sellingRate) != 0) return false;
        if (arrivalDate != null ? !arrivalDate.equals(schedule.arrivalDate) : schedule.arrivalDate != null)
            return false;
        if (currency != null ? !currency.equals(schedule.currency) : schedule.currency != null) return false;
        if (departureDate != null ? !departureDate.equals(schedule.departureDate) : schedule.departureDate != null)
            return false;
        if (destination != null ? !destination.equals(schedule.destination) : schedule.destination != null)
            return false;
        if (origin != null ? !origin.equals(schedule.origin) : schedule.origin != null) return false;
        if (tariffDate != null ? !tariffDate.equals(schedule.tariffDate) : schedule.tariffDate != null) return false;
        if (transportCompany != null ? !transportCompany.equals(schedule.transportCompany) : schedule.transportCompany != null)
            return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result;
        long temp;
        result = origin != null ? origin.hashCode() : 0;
        result = 31 * result + (destination != null ? destination.hashCode() : 0);
        temp = Double.doubleToLongBits(primeCost);
        result = 31 * result + (int) (temp ^ (temp >>> 32));
        temp = Double.doubleToLongBits(sellingRate);
        result = 31 * result + (int) (temp ^ (temp >>> 32));
        result = 31 * result + (tariffDate != null ? tariffDate.hashCode() : 0);
        result = 31 * result + (transportCompany != null ? transportCompany.hashCode() : 0);
        result = 31 * result + (departureDate != null ? departureDate.hashCode() : 0);
        result = 31 * result + (arrivalDate != null ? arrivalDate.hashCode() : 0);
        result = 31 * result + (currency != null ? currency.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("Schedule{");
        sb.append("id=").append(id);
        sb.append(", origin=").append(origin);
        sb.append(", destination=").append(destination);
        sb.append(", primeCost=").append(primeCost);
        sb.append(", sellingRate=").append(sellingRate);
        sb.append(", tariffDate=").append(tariffDate);
        sb.append(", transportCompany=").append(transportCompany);
        sb.append(", departureDate=").append(departureDate);
        sb.append(", arrivalDate=").append(arrivalDate);
        sb.append(", currency=").append(currency);
        sb.append('}');
        return sb.toString();
    }

}
